import { ByteView } from "./byte/ByteView";

export type NetData = (string | ArrayBufferLike | Blob | ArrayBufferView);
export type ProtocolID = number;
export type Protocol = {id:ProtocolID, len:number, data:any};
export type HeadDecoder = (buffer: ByteView) => Protocol;
export type HeadEncoder = (buffer: ByteView, id:ProtocolID, len:number) => any;

// 协议helper
export interface IProtocolHelper {
    decode(buffer: ByteView):Protocol;
    heartbeat():Protocol;
}

// 网络提示接口
export interface INetworkTips {
    onConnecting():void;
    onConnectSuccess():void;
    onConnectFailed():void;
    onClosed():void;
    onMessage():void;
    onFlush():void;
}